﻿using System;
using System.Globalization;
using System.Windows.Data;

namespace AppTemplate.UI.Converters
{
    public class IconFontUnicodeConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value is not string)
                return string.Empty;

            char[] chars = ((string)value).ToCharArray();
            int val = System.Convert.ToInt32(chars[0]);
            return $"&#x{val:x};";
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
